package com.vidyu.datalayer.dataaccesscomponents.impl;

import com.vidyu.businesslayer.businessentities.Session;
import com.vidyu.datalayer.dataaccesscomponents.SessionDao;
import com.vidyu.datalayer.dataaccesscomponents.SessionDbHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created by IntelliJ IDEA.
 * Session: eyalsa
 * Date: 12/03/12
 * Time: 10:33
 * Handles the session db
 */
@Component
public class SessionDbHandlerImpl implements SessionDbHandler {

    @Autowired
    private SessionDao sessionDao;


    public Session findById(long id) {
        return sessionDao.findById(id);
    }


    @Transactional(readOnly = false, propagation = Propagation.NESTED)
    public long save(String name){
        Session session = new Session();
        session.setParams(name);
        return sessionDao.save(session);
    }
}
